package com.qiantu.phone.ui.shotview;

import com.qiantu.phone.R;
import static com.qiantu.phone.ui.uiutil.LLDeviceUtil.STROKE_PERCENTAGE;

import android.content.Context;
import android.text.TextUtils;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.SoundEffectConstants;
import android.view.View;

import androidx.lifecycle.LifecycleOwner;

import com.hjq.http.listener.HttpCallback;
import com.hjq.toast.ToastUtils;
import com.qiantu.api.db.LLDeviceDBManager;
import com.qiantu.api.entity.DeviceState;
import com.qiantu.api.http.LLHttpManager;
import com.qiantu.api.http.model.HttpData;
import com.qiantu.phone.app.AppActivity;
import com.qiantu.phone.ui.fragment.device.BlindCurtainFragment;
import com.qiantu.phone.ui.uiutil.LLDeviceUtil;
import com.qiantu.phone.widget.KHCurtainSeek;
import com.qiantu.phone.widget.RollerShutterSeek;
import com.qiantu.phone.widget.VerticalStatusSeekBar;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;

public class BlindCurtainShotView extends BaseDeviceActView{
    private RollerShutterSeek mRollerShutterSeek;
    private VerticalStatusSeekBar statusSeekBar;

    public BlindCurtainShotView(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.blind_curtain_shot_view;
    }

    @Override
    public void initView() {
        mRollerShutterSeek = findViewById(R.id.roller_shutter_seek);
        statusSeekBar = findViewById(R.id.status_seek_bar);
        mRollerShutterSeek.setOnChangeListener(new RollerShutterSeek.OnChangeListener() {
            @Override
            public void onProgressChanged(int progress) {

            }

            @Override
            public void onStartTrackingTouch() {

            }

            @Override
            public void onValueChanged(int progress) {
                addAct(STROKE_PERCENTAGE, (100 - progress) + "");
            }
        });
        statusSeekBar.setOnSeekBarChangeListener(new VerticalStatusSeekBar.OnSeekBarChangeListener() {
            @Override
            public void onValueChanged(int value) {
            }

            @Override
            public void onStartTrackingTouch() {

            }

            @Override
            public void onStopTrackingTouch(int value) {
                addAct(LLDeviceUtil.AMGLE, value + "");
            }
        });
    }

    @Override
    public void updateView() {
        //根据已保存动作指令集合更新UI
        String strokePercentage = getState(STROKE_PERCENTAGE, null);
        if(TextUtils.isEmpty(strokePercentage)){
            mRollerShutterSeek.isNotSet(true);
        }else{
            mRollerShutterSeek.setProgress(100 - Integer.valueOf(strokePercentage));
        }

        String angle = getState(LLDeviceUtil.AMGLE, null);
        if(TextUtils.isEmpty(strokePercentage)){
            statusSeekBar.isNotSet(true);
        }else{
            statusSeekBar.setValue(Integer.valueOf(angle));
        }
    }

}